package net.wsfcp.android.http.mvp.presenter;

import net.wsfcp.android.base.BasePresenter;
import net.wsfcp.android.http.mvp.IModel;
import net.wsfcp.android.http.mvp.contract.ChangePasswordContract;
import net.wsfcp.android.http.mvp.model.ChangePasswordModel;
import net.wsfcp.android.ui.view.my.activity.ChangePasswordActivity;

import java.util.HashMap;

/**
 * Created by Shaoboyang on 2018/12/14.
 */
//修改密码
public class ChangePasswordPresenter extends BasePresenter<ChangePasswordActivity> implements
        ChangePasswordContract.ChangePasswordPresenter {

    @Override
    public void changePassword(String oldpwd, String newpwd) {
        if (!getIView().checkNull()) {
            ((ChangePasswordModel) getiModelMap().get("changepassword")).changePassword(oldpwd, newpwd, new ChangePasswordModel
                    .ChangePasswordInfoHint() {
                @Override
                public void changePasswordSuccessInfo() {
                    getIView().changePasswordSuccess();
                }

                @Override
                public void changePasswordFailInfo(String str) {
                    getIView().changePasswordFail(str);
                }


            });
        }
    }


    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new ChangePasswordModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> map = new HashMap<>();
        map.put("changepassword", models[0]);
        return map;
    }


}
